package fun.formoji.alg.controller;

import fun.formoji.alg.resp.CouponScoreResultVo;
import fun.formoji.alg.resp.GbdtAlgResultVo;
import fun.formoji.alg.resp.LfmAlgResultVo;
import fun.formoji.alg.resp.ShoppingBasketResultVo;
import fun.formoji.commons.config.SecurityConfig;
import fun.formoji.commons.model.RestResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.assertj.core.util.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: h
 * @Date: 2022/8/13 21:21
 */
@Api(tags = "offline")
@RestController
@RequestMapping("/offlineAlg")
@RefreshScope
public class OfflineAlgcontroller  {
    //    @Value()
//    @NacosValue(value="${security.excludes}",autoRefreshed = true)
    @Value(value = "${security.excludes}")
    private String act;

    @Autowired
    private SecurityConfig securityConfig;

    
    public RestResponse<LfmAlgResultVo> lfm(String userId) {
        return null;
    }

    
    public RestResponse<GbdtAlgResultVo> gbdt(String userId) {
        return null;
    }

    @ApiOperation("coupon")
    @GetMapping("/couponScore")
    
    public RestResponse<CouponScoreResultVo> couponScore(@RequestParam String userId) {
        System.out.println("@value的值-=--->" + act);
        System.out.println("@properties的值-=--->" + securityConfig.getExcludes());

        String[] val = securityConfig.getExcludes().split(",");
        CouponScoreResultVo build = CouponScoreResultVo
                .builder()
                .keycodes(Lists.newArrayList(val))
                .userId(userId)
                .build();
        return RestResponse.ok(build);
    }

    
    public RestResponse<ShoppingBasketResultVo> shoppingBasket(List<String> itemIds) {
        return null;
    }


}
